/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GUI;
import Rutas.*;
import Rutas.BLAST;
import Rutas.NeedlemanWunsch;
import java.io.FileReader;
import java.util.Scanner;

/**
 *
 * @author Zoila
 */
public class InputOf extends javax.swing.JFrame {

    /**
     * Creates new form Input
     */
    public InputOf() {
        initComponents();
        this.setLocationRelativeTo(null);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jButton1 = new javax.swing.JButton();
        btnAceptar = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();

        jButton1.setText("jButton1");

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Input ");

        btnAceptar.setText("BLAST");
        btnAceptar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAceptarActionPerformed(evt);
            }
        });

        jButton2.setText("NeedlemanWunsch");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jButton3.setText("Ruta");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(95, 95, 95)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jButton2)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(25, 25, 25)
                                .addComponent(btnAceptar))))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(124, 124, 124)
                        .addComponent(jButton3)))
                .addContainerGap(103, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(40, 40, 40)
                .addComponent(btnAceptar)
                .addGap(26, 26, 26)
                .addComponent(jButton2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jButton3)
                .addContainerGap(14, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnAceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAceptarActionPerformed
        // TODO add your handling code here:
    //   Rutas.GestorRutas.IniciarSimulacion((int)numRutas.getValue(),(int)numBuses.getValue());
       
     BLAST b = new BLAST();
       b.algoritmo();
       System.exit(0);
    }//GEN-LAST:event_btnAceptarActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:
        NeedlemanWunsch a = new NeedlemanWunsch(0,-1);
        String ideal="";
        int[][] score;
        int[][] rast;
        int l1, l2,i,j;
        try{
            Scanner in = new Scanner(new FileReader ("rutaIn.txt"));
            while (in.hasNextLine()){
                ideal= in.nextLine();
            }
            in.close();
        }
        catch(Exception ie){
            System.out.println(ie.toString());
        }
        /*System.out.print("Ingresar ruta ideal: ");
        ideal  = in.next();*/
        a.setSeq1(ideal);
        l1 = ideal.length();
        
        /*System.out.print("Ingresar ruta obtenida: ");
        ideal  = in.next();*/
        try{
            Scanner in = new Scanner(new FileReader("rutaBus.txt"));
            while (in.hasNextLine()){
                ideal= in.nextLine();
            }
            in.close();
        }
        catch(Exception ie){
            System.out.println(ie.toString());
        }
        a.setSeq2(ideal);
        l2 = ideal.length();
        
        a.creaMatrix();
        /*score = a.matrix;
        rast = a.rastreo;
        System.out.println("MATRIZ DE SCORES");
        for(i=0; i<=l2;i++){
            for(j=0;j<=l1;j++){
                System.out.print(""+score[i][j] + " ");
            }
            System.out.println();
        }
        System.out.println();
        System.out.println("MATRIZ DE RASTREO");
        for(i=0; i<=l2;i++){
            for(j=0;j<=l1;j++){
                System.out.print(""+rast[i][j] + " ");
            }
            System.out.println();
        }*/
        a.rastrea();
        System.out.println("Seq1: " + a.fiSeq1);
        System.out.println("Seq2: " + a.fiSeq2); 
        a.compara();
        System.exit(0);
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        // TODO add your handling code here:
        //Rutas.GestorRutas.IniciarSimulacion(50,20);
        TabuFiorella a = new TabuFiorella(20);
        a.algoritmo();
        System.exit(0);
    }//GEN-LAST:event_jButton3ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(InputOf.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(InputOf.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(InputOf.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(InputOf.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new InputOf().setVisible(true);                
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAceptar;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    // End of variables declaration//GEN-END:variables
}
